package com.project.bean;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.List;
/**项目实体类*/
public class ProjectBean {
    /**项目id*/
    private int projId;
    private String name;
    private String customer;
    /**项目资金*/
    private int money;
    /**项目开始时间*/
    private LocalDate startDate = LocalDate.now();
    /**交付时间*/
    private LocalDate endDate;
    private String state = "开发中";

    /**项目参与人数*/
    private int count;
    /**项目剩余天数*/
    private String day;
    /**参与员工*/
    private List<ProgressBean> progBean;

    public ProjectBean() {
    }

    public ProjectBean(String name, String customer, int money, LocalDate endDate) {
        this.name = name;
        this.customer = customer;
        this.money = money;
        this.endDate = endDate;
    }

    public ProjectBean(String name, String customer,
                       int money, LocalDate startDate, LocalDate endDate,
                       String state, int count, String day) {
        this.name = name;
        this.customer = customer;
        this.money = money;
        this.startDate = startDate;
        this.endDate = endDate;
        this.state = state;
        this.count = count;
        this.day = day;
    }

    public List<ProgressBean> getProgBean() {
        return progBean;
    }

    public void setProgBean(List<ProgressBean> progBean) {
        this.progBean = progBean;
    }

    public int getProjId() {
        return projId;
    }

    public void setProjId(int projId) {
        this.projId = projId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCustomer() {
        return customer;
    }

    public void setCustomer(String customer) {
        this.customer = customer;
    }

    public int getMoney() {
        return money;
    }

    public void setMoney(int money) {
        this.money = money;
    }

    public LocalDate getStartDate() {
        return startDate;
    }

    public void setStartDate(LocalDate startDate) {
        this.startDate = startDate;
    }

    public LocalDate getEndDate() {
        return endDate;
    }

    public void setEndDate(LocalDate endDate) {
        this.endDate = endDate;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public String getDay() {
        if ("交付使用".equals(state)){
            return "已交付";
        }
        else {
            int day = (int) ChronoUnit.DAYS.between(LocalDate.now(), endDate);
            return day+"";
        }
    }

    public void setDay(String day) {
        this.day = day;
    }

    @Override
    public String toString() {
        return "ProjectBean{" +
                "projId=" + projId +
                ", name='" + name + '\'' +
                ", customer='" + customer + '\'' +
                ", money=" + money +
                ", startDate=" + startDate +
                ", endDate=" + endDate +
                ", state='" + state + '\'' +
                ", count=" + count +
                ", day='" + this.getDay() + '\'' +
                ", progBean=" + progBean +
                "}\n";
    }
}
